package me.leiusual.sharing.repository.datasource

import androidx.lifecycle.MutableLiveData
import androidx.paging.DataSource
import me.leiusual.sharing.api.ApiSharing
import me.leiusual.sharing.api.model.Invited

/**
 * author: leiusual
 * create on: 2019-08-07
 * description:
 */
class UserInvitedDataSourceFactory(
    private val apiSharing: ApiSharing,
    private val currentUserId: Long,
    private val targetUserId: Long
) : DataSource.Factory<Int, Invited.Response.User>() {

  val userInvitedDataSource = MutableLiveData<UserInvitedDataSource>()

  override fun create(): DataSource<Int, Invited.Response.User> {
    val dataSource = UserInvitedDataSource(apiSharing, currentUserId, targetUserId)
    userInvitedDataSource.postValue(dataSource)
    return dataSource
  }
}